public class Hanoi {
    public static int countNum=0;//可统计要移动多少次
    public static void hanio(int n,char pos1,char pos2,char pos3) {
        if(n==1){
            move(pos1,pos3);
        }
        else{
            hanio(n-1,pos1,pos3,pos2);
            move(pos1,pos3);
            hanio(n-1,pos2,pos1,pos3);
        }
    }
    public static void move(char posSrc,char posDest) {
        countNum++;
        System.out.println(posSrc+"->"+posDest);
    }
    public static void main(String[] args) {
        hanio(3,'A','B','C');
        System.out.println(countNum);
    }
}
